// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   FileUtils.java

package com.hfstu.file.utils;

import com.hfstu.file.FileServerInfo;
import java.io.File;
import java.util.Calendar;

public final class FileUtils
{

	public FileUtils()
	{
	}

	public static String getRelativeDir()
	{
		Calendar current = Calendar.getInstance();
		String ret = (new StringBuilder(String.valueOf(current.get(1)))).append("/").append(current.get(2) + 1).append("/").append(current.get(5)).toString();
		String fullDir = (new StringBuilder(String.valueOf(FileServerInfo.getInstance().getFilePath()))).append("/").append(ret).toString();
		File file = new File(fullDir);
		synchronized (com/hfstu/file/utils/FileUtils)
		{
			if (!file.exists() && !file.mkdirs())
				throw new RuntimeException((new StringBuilder("create dir failure. dir : ")).append(fullDir).toString());
		}
		return ret;
	}

	public static String getFileExtName(String filename)
	{
		if (filename == null)
			return "";
		int index = filename.lastIndexOf(".");
		if (index < 0)
			return "";
		else
			return filename.substring(index + 1);
	}

	public static boolean waitingForFileAvailable(String filename, int sleepInterval, int waitTimeForCreation, int totalWaitTime)
	{
		File file;
		int waitTime;
		int waitForCreation;
		file = new File(filename);
		waitTime = 0;
		waitForCreation = 0;
_L2:
		if (!file.exists())
			break MISSING_BLOCK_LABEL_49;
		if (file.renameTo(file.getAbsoluteFile()))
			return true;
		throw new Exception("Name change failed.");
		waitForCreation += sleepInterval;
		throw new Exception("No File.");
		Exception e;
		e;
		try
		{
			Thread.sleep(sleepInterval);
		}
		catch (InterruptedException e1)
		{
			e1.printStackTrace();
		}
		waitTime += sleepInterval;
		if (waitTime >= totalWaitTime || waitForCreation >= waitTimeForCreation)
			return false;
		if (true) goto _L2; else goto _L1
_L1:
	}
}
